<script>


$(document).ready(function() {
	$("#signinbutton").click(function () {
		
		var email = $("#email").val();
		var password = $("#password").val();
		var rememberMe = $("input[id=remember_me]:checked").length;
		
		$.ajax({
		    type: 'POST',
		    url: context+'home/signin',
		    dataType: 'json',
		    async: false,
		    data:{'email':email,'password':password,'remember_me':rememberMe},
		    success: function(data){
			 
			    if(data['success'])
			    {
			    	$(location).attr('href',context+'user');
			    }
			    else{
			    	
			    	 $("#error_authenticate span").html(data['error']);
				 }
		    },
		    error: function(xhr, status, thrown){
		    	
		    	 $("#error_authenticate span").html(xhr.responseText);
		    }
		});
		return false;
	});

$("#loginfacebookbutton").click(function () {
		$.ajax({
		    type: 'POST',
		    url: context+'home/fblogin',
		    dataType: 'json',
		    async: false,
		    success: function(data){
			   if(data['success'])
			    {
				   if(data['url'])
				   {
			    	$(location).attr('href',data['url']);
				   }
				   else{
					   $(location).attr('href',context+'user');
					   }
			    }
			    else{
			    	 $("#error_authenticate span").html(data['error']);
				 }
		    },
		    error: function(xhr, status, thrown){
		    	 $("#error_authenticate span").html(xhr.responseText);
		    }
		});
		return false;
	});
});


</script>

<div class="hero-unit">

<div>
Passenger Home page
  <div id="error_authenticate">
     <span></span>
  </div>
  <div>
     Login
      <input id="email" type="text" value="difson@gmail.com" />
  </div>
  <div>
     Password
      <input id="password" type="password" value="armando" />
  </div>
  
  <div>
      <input id="remember_me" type="checkbox" value="1">
      Remember me
  </div>
</div>
<button id="signinbutton">Log in</button>

 <a href="" onclick="location.href=context+'user/signon';return false;">Create new account </a>
 |
 <a href="" onclick="location.href=context+'user/forgotpassword';return false;">I forgot my password </a>
 </div>

 <button id="loginfacebookbutton">Log with Facebook</button>
 
<div class="row">

</div>
